<template>
  <div v-loading="dataLoading" class="d_container">
    <!--    顶部导航条-->
    <div class="topNav">
      <div>
        <span class="back pointer" @click="Back"
          ><i class="el-icon-arrow-left" /> 返回</span
        >
        <span class="fw">彩稿审核</span>
      </div>
      <div class="orderTopBtn">
        <el-button
          v-if="productFrom.checkBillData.checkBillState === 0"
          size="small"
          icon="el-icon-close"
          type="danger"
          @click="refush"
          v-permission="'MenuCode1-2-2'"
          >审核拒绝</el-button
        >
        <el-button
          v-if="productFrom.checkBillData.checkBillState === 0"
          size="small"
          icon="el-icon-check"
          type="success"
          @click="passSH"
          v-permission="'MenuCode1-2-3'"
          >审核通过</el-button
        >
        <el-button
          v-if="productFrom.checkBillData.checkBillState === 3"
          size="small"
          icon="el-icon-close"
          type="danger"
          @click="refush"
          v-permission="'MenuCode1-2-4'"
          >撤审拒绝</el-button
        >
        <el-button
          v-if="productFrom.checkBillData.checkBillState === 3"
          size="small"
          icon="el-icon-check"
          type="success"
          @click="passCS"
          v-permission="'MenuCode1-2-5'"
          >撤审通过</el-button
        >
      </div>
    </div>
    <div class="subTip">
      <dl>
        <dt>彩稿单号</dt>
        <dd>{{ productFrom.checkBillData.colorDraftNo || "系统自动生成" }}</dd>
      </dl>
      <dl>
        <dt>创建日期</dt>
        <dd>
          {{
            productFrom.checkBillData.applyTime ||
            dayjs().format("YYYY-MM-DD")
          }}
        </dd>
      </dl>
      <dl>
        <dt>创建人员</dt>
        <dd>{{ productFrom.checkBillData.applyPersonName || name }}</dd>
      </dl>
    </div>
    <div class="d_mainCenter">
      <el-form
        ref="orderForm"
        label-position="left"
        :model="productFrom"
        :rules="rules"
        label-width="110px"
        class="orderForm"
      >
        <div class="d_left">
          <div class="d_orderDetails m0">
            <div class="item">
              <div class="cTitle">
                <h3>订单信息</h3>
              </div>
              <dl>
                <dt>订单单号</dt>
                <dd>{{ productFrom.orderBaseData.xieYiShuHao || "--" }}</dd>
              </dl>
              <dl>
                <dt>客户单号</dt>
                <dd>{{ productFrom.orderBaseData.customerBillNo || "--" }}</dd>
              </dl>
              <dl>
                <dt>合同号</dt>
                <dd>{{ productFrom.orderBaseData.contractCode || "--" }}</dd>
              </dl>
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>产品信息</h3>
              </div>
              <dl>
                <dt>产品名称</dt>
                <dd>
                  {{ productFrom.checkBillData.productName || "--" }}
                </dd>
              </dl>
              <dl>
                <dt>产品编码</dt>
                <dd>
                  {{ productFrom.checkBillData.productCode || "--" }}
                </dd>
              </dl>
              <dl>
                <dt>产品板面</dt>
                <dd>{{ productFrom.checkBillData.printingSurface || "--" }}</dd>
              </dl>
              <dl>
                <dt>产品版本</dt>
                <dd>{{ productFrom.checkBillData.productVersions || "--" }}</dd>
              </dl>
              <dl>
                <dt>产品库存</dt>
                <dd>{{ productFrom.stockQuantity }}</dd>
              </dl>
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>业务信息</h3>
              </div>
              <dl>
                <dt>标签套数</dt>
                <dd>
                  {{ productFrom.orderBaseData.taoZhuangQuantity || "--"
                  }}<span class="unit">{{
                    productFrom.orderBaseData.taoZhuangQuantity ==
                    productFrom.orderBaseData.tagSumQuantity
                      ? "枚"
                      : "套"
                  }}</span>
                </dd>
              </dl>
              <dl>
                <dt>标签枚数</dt>
                <dd>
                  {{ productFrom.orderBaseData.tagSumQuantity || "--"
                  }}<span class="unit">枚</span>
                </dd>
              </dl>
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>数据信息</h3>
              </div>
              <dl>
                <dt>数据来源</dt>
                <dd>
                  {{ productFrom.orderBaseData.dataComeFromName || "--" }}
                </dd>
              </dl>
              <dl>
                <dt>数据数量</dt>
                <dd>{{ productFrom.orderBaseData.tagDataQuantity || "--" }}</dd>
              </dl>
              <dl>
                <dt>数据状态</dt>
                <dd>
                  {{ productFrom.orderBaseData.dataProduceState || "--" }}
                </dd>
              </dl>
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>套装关系</h3>
              </div>
              <labelTree :tree-data="productFrom.packageRelations" />
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>产品包装</h3>
              </div>
              <dl>
                <dt>成品样式</dt>
                <dd>
                  {{ productFrom.packageData.productStyleName || "--" }}
                </dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle !== 1">
                <dt>出标方向</dt>
                <dd>
                  {{ productFrom.packageData.outDirectionName || "--" }}
                </dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle === 2">
                <dt>卷向</dt>
                <dd>
                  {{ productFrom.packageData.scrollDirectionName || "--" }}
                </dd>
              </dl>
              <dl>
                <dt>贴标方式</dt>
                <dd>{{ productFrom.packageData.tagAffixWayName || "--" }}</dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle === 2">
                <dt>卷芯大小</dt>
                <dd>
                  {{ productFrom.packageData.mandrelSize || "--"
                  }}<span class="unit">mm</span>
                </dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle === 2">
                <dt>外直径不超过</dt>
                <dd>
                  {{ productFrom.packageData.notOverDiameter || "--"
                  }}<span class="unit">mm</span>
                </dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle === 2">
                <dt>每卷等于</dt>
                <dd>
                  {{ productFrom.packageData.pageEqualTags || "--"
                  }}<span class="unit">{{
                    productFrom.packageData.taoZhuangQuantity ==
                    productFrom.packageData.tagSumQuantity
                      ? "枚"
                      : "套"
                  }}</span>
                </dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle !== 2">
                <dt>每张等于</dt>
                <dd>
                  {{ productFrom.packageData.pageEqualTags || "--"
                  }}<span class="unit">{{
                    productFrom.orderBaseData.productUnion
                  }}</span>
                </dd>
              </dl>
              <dl v-if="productFrom.packageData.productStyle !== 2">
                <dt>每包等于</dt>
                <dd>
                  {{ productFrom.packageData.packageEqualPages || "--"
                  }}<span class="unit">张</span>
                </dd>
              </dl>
              <dl>
                <dt>每箱等于</dt>
                <dd>
                  {{ productFrom.packageData.boxEqualPackages || "--"
                  }}<span class="unit">{{
                    productFrom.packageData.productStyle !== 2 ? "包" : "卷"
                  }}</span>
                </dd>
              </dl>
              <dl>
                <dt>每箱共计</dt>
                <dd>
                  {{ productFrom.packageData.boxEqualTags || "--"
                  }}<span class="unit">{{
                    productFrom.orderBaseData.productUnion
                  }}</span>
                </dd>
              </dl>
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>订单备注</h3>
              </div>
              <div class="d_remark">
                {{ productFrom.orderBaseData.orderRemark }}
              </div>
            </div>
            <div class="item">
              <div class="cTitle">
                <h3>其他信息</h3>
              </div>
              <dl>
                <dt>业务员</dt>
                <dd>{{ productFrom.orderBaseData.salesmanName || "--" }}</dd>
              </dl>
              <dl>
                <dt>联系电话</dt>
                <dd>{{ productFrom.orderBaseData.salesmanMobile || "--" }}</dd>
              </dl>
            </div>
          </div>
        </div>
        <div class="d_tag">
            <div class="cTitle">
              <h3>标签信息</h3>
            </div>
            <LableShow :dataArr="productFrom.orderTagDataList"></LableShow>
        </div>
        <div class="d_content not">
          <div class="cTitle">
            <h3>彩稿信息</h3>
          </div>
          <div class="tagsBox">
            <el-row>
              <el-col>
                <div class="pic-left">
                  <div class="colorPic flex flex_center">
                    <div
                      v-if="picList && picList.length > 0"
                      class="flex w100 flex_wrap"
                    >
                      <div
                        v-for="imgsrc in picList"
                        :key="imgsrc.draftFilePreviewUrl"
                        class="img_c"
                      >
                        <div v-show="imgsrc.colorDraftTypeName" class="text">
                          {{ imgsrc.colorDraftTypeName }}
                        </div>
                        <div
                          class="yulan flex-column-center pointer"
                          @click="previewColor(imgsrc.draftFilePreviewUrl)"
                        >
                          <i class="iconfont yulanIco" />
                        </div>

                        <img
                          class="img_i"
                          style="max-width: 90%"
                          :src="imgsrc.draftFilePreviewUrl"
                          alt=""
                        />
                      </div>
                      <el-image-viewer
                        v-show="isShadeShow"
                        :initial-index="0"
                        :on-close="onClose"
                        :url-list="urlList"
                      />
                    </div>
                    <el-empty v-else description="暂无彩稿图" />
                  </div></div
              ></el-col>
            </el-row>
          </div>
          <div class="cTitle flex flex_between">
            <h3>颜色信息</h3>
            <span
              class="c_3F61F1 pointer"
              @click="handleSelectColor"
              v-if="
                productFrom.checkBillData.checkBillState == 0
              "
              ><i class="iconfont xinjian" /> 添加颜色</span
            >
          </div>
          <div class="tableBox">
            <!-- <div class="tt flex flex_between">
              <span class="fw">印刷颜色</span>
              <span
                class="c_3F61F1 mr15 pointer"
                @click="showColor = true"
              ><i class="el-icon-plus mr5" /> 选择</span>
            </div> -->
            <div ref="tableCon" class="bigdialogTbCon">
              <el-table
                :data="productFrom.printColorList"
                border
                style="width: 100%"
              >
              <el-table-column
              type="index"
              label="序号"
              width="100"
            />
            <el-table-column
              prop="colorTypeName"
              label="颜色类型"
              width="110"
            >
            <template slot-scope="{ row }">
                <el-select
                        filterable
                  v-model="row.colorType"
                  placeholder="请选择颜色类型"
                  size="mini"
                  :disabled="
                        productFrom.checkBillData.checkBillState != 0
                      "
                >
                  <el-option label="普通" value="1" />
                  <el-option label="专色" value="2" />
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              label="颜色名称"
              prop="colorName"
              width="110"
            >
            <template slot-scope="{ row }">
                <el-input
                  v-model="row.colorName"
                  placeholder="请输入"
                  size="mini"
                  :disabled="
                        productFrom.checkBillData.checkBillState != 0
                      "
                />
              </template>
            </el-table-column>
                <el-table-column
                  label="参考"
                  prop="colorReference"
                  show-overflow-tooltip
                  width="130"
                >
                  <template slot-scope="{ row }">
                    <el-select
                        filterable
                      v-model="row.colorReference"
                      placeholder="请选择参考"
                      size="mini"
                      :disabled="
                        productFrom.checkBillData.checkBillState != 0
                      "
                    >
                      <el-option label="封样" :value="3" />
                      <el-option label="样标" :value="2" />
                      <el-option label="彩稿" :value="1" />
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column
                  label="备注"
                  show-overflow-tooltip
                  min-width="150"
                  prop="colorRemark"
                >
                  <template slot-scope="{ row }">
                    <el-input
                      v-model="row.colorRemark"
                      placeholder="请输入"
                      size="mini"
                      :disabled="
                        productFrom.checkBillData.checkBillState != 0
                      "
                    />
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  fixed="right"
                  show-overflow-tooltip
                  width="80"
                  align="center"
                  v-if="
                    productFrom.checkBillData.checkBillState == 0
                  "
                >
                  <template slot-scope="scope">
                    <el-tooltip
                      class="item"
                      effect="dark"
                      content="删除"
                      placement="right-start"
                    >
                      <span
                        class="pointer"
                        @click="deleteRow(scope.row, scope.$index)"
                        ><i class="el-icon-delete"
                      /></span>
                    </el-tooltip>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <div class="cTitle">
            <h3>彩稿备注</h3>
          </div>
          <div class="maskBox">
            <div v-if="productFrom.checkBillData.uploadRemark">
              {{ productFrom.checkBillData.uploadRemark }}
            </div>
            <p v-else>暂无备注</p>
          </div>
          <div class="cTitle">
            <h3>撤审原因</h3>
          </div>
          <div class="maskBox">
            <div v-if="productFrom.checkBillData.applyRemark">
              {{ productFrom.checkBillData.applyRemark }}
            </div>
            <p v-else>暂无备注</p>
          </div>
          <div class="cTitle">
            <h3>审核结果</h3>
          </div>
          <div class="maskBox">
            <!--审核通过-->
            <div v-if="productFrom.checkBillData.checkBillState === 1">
              <el-alert
                :title="productFrom.checkBillData.checkResultName"
                type="success"
                description="彩稿业务人员已审核通过"
                show-icon
                :closable="false"
              />
            </div>
            <!--审核失败-->
            <div v-else-if="productFrom.checkBillData.checkBillState === 2">
              <el-alert
                :title="productFrom.checkBillData.checkResultName"
                type="error"
                :description="productFrom.checkBillData.checkRemark"
                show-icon
                :closable="false"
              />
            </div>
            <!--待审核-->
            <div v-else>
              <el-alert
                :title="productFrom.checkBillData.checkBillStateName"
                type="info"
                show-icon
                :closable="false"
              />
            </div>
          </div>
        </div>
      </el-form>
    </div>
    <!-- 遮罩div   -->
    <!-- <div
      v-if="isShadeShow"
      class="shadeBox flex-column-center"
      @click="colosrSheBox"
    >
      <span
        class="colseShadebox pointer"
        @click="colosrSheBox"
      ><i
        class="el-icon-error"
      /></span>
      <img :src="colorImagUrl" alt="">
    </div> -->

    <!--彩稿颜色 -->
    <el-dialog
      append-to-body
      title="选择颜色"
      :visible.sync="isSemidialog"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog"
      width="70%"
      @close="closeSemiDialog"
      @open="opanColor"
    >
      <div class="dialogDody marDialog flex flex_column">
        <div class="btnCon flex flex_between">
          <!--      搜索框-->
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-plus"
            @click="addPackge"
            >新建</el-button
          >
          <div class="search">
            <el-input
              v-model="SemiSearch.likeWords"
              placeholder="输入关键字"
              size="small"
            >
              <el-button
                slot="append"
                :loading="marLoading"
                type="primary"
                icon="el-icon-search"
                :disabled="marLoading"
                element-loading-spinner="el-icon-loading"
                @click="openmater"
              >
                搜索
              </el-button>
            </el-input>
          </div>
        </div>

        <!--    高级搜索版块-->
        <div class="seniorSearch flex flex_between">
          <div>
            <el-radio-group
              v-model="SemiSearch.colorType"
              size="mini"
              @change="changeExclusive"
            >
              <el-radio-button label="0">全部</el-radio-button>
              <el-radio-button label="1">普通</el-radio-button>
              <el-radio-button label="2">专色</el-radio-button>
            </el-radio-group>
          </div>
        </div>
        <!-- 表格区域       -->
        <div class="tableCon not">
          <el-table
            :data="colorList"
            border
            height="500"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column prop="selection" width="55">
              <el-table-column type="selection" width="55" />
              <el-table-column prop="colorName" label="颜色名称" />
              <el-table-column prop="colorTypeName" label="类型" />
              <el-table-column prop="cmykValue" label="CMYK值" />
              <el-table-column prop="colorValue" label="HEX/HTML值" />
              <el-table-column prop="colorRemark" label="备注" />
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isSemidialog = false">取 消</el-button>
        <!-- 选择 -->
        <el-button
          v-loading="addLoading"
          :disabled="addLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="saveColorManuscript"
        >
          确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 新建颜色   -->
    <el-dialog
      :title="'新增颜色'"
      :visible.sync="isAddMaterriel"
      :close-on-click-modal="false"
      custom-class="comDialog "
      width="30%"
      @close="closeDialog"
    >
      <div class="dialogDody">
        <div class="addWuliaoBox">
          <el-form
            ref="materForm"
            :model="materForm"
            :rules="materFormRules"
            :label-position="'left'"
            label-width="120px"
            class="dialogForm dialogInlineForm"
          >
            <el-row>
              <el-col>
                <el-form-item label="颜色编号">
                  <el-input
                    v-model="materForm.colorCode"
                    placeholder="系统自动生成"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="颜色名称" prop="colorName">
                  <el-input v-model="materForm.colorName" size="mini" />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="颜色类型" prop="colorType">
                  <el-select
                        filterable
                    v-model="materForm.colorType"
                    placeholder="请选择 颜色类型"
                    size="mini"
                  >
                    <el-option
                      v-for="item in colorTypetList"
                      :key="item.colorTypetNo"
                      :label="item.colorTypeName"
                      :value="item.colorTypetNo"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="CMYK值" prop="cmykValue">
                  <el-input
                    v-model="materForm.cmykValue"
                    placeholder="用逗号隔开, 如(c100,k100)"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="HEX/HTML值" prop="colorValue">
                  <el-input
                    v-model="materForm.colorValue"
                    size="mini"
                    placeholder="如#ffffff"
                    class="color-select"
                    ><el-color-picker
                      slot="append"
                      v-model="materForm.colorValue"
                      size="mini"
                    />
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col>
                <el-form-item label="排序" prop="colorSort">
                  <el-input
                    v-model="materForm.colorSort"
                    onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item
              label="备注"
              prop="colorRemark"
              class="inlineText mt5"
            >
              <el-input
                v-model="materForm.colorRemark"
                type="textarea"
                placeholder="请输入备注"
                size="mini"
                clearable
              />
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isAddMaterriel = false">取 消</el-button>
        <el-button
          v-loading="addMaterrielLoading"
          :disabled="addMaterrielLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="reSaveMater"
          >继续新增</el-button
        >
        <!--  新建保存      -->
        <el-button
          v-loading="addMaterrielLoading"
          :disabled="addMaterrielLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="saveMater"
          >保存</el-button
        >
      </div>
    </el-dialog>

    <!-- 撤审原因   -->
    <el-dialog
      :title="'拒绝原因'"
      :visible.sync="isNopassshow"
      :close-on-click-modal="false"
      custom-class="comDialog"
      width="40%"
      @close="closePassDialog"
      @open="openPass"
    >
      <div class="dialogDody">
        <el-form
          ref="passForm"
          :model="passForm"
          class="dialogForm"
          :rules="passFormrules"
        >
          <el-form-item prop="checkRemark">
            <el-input
              v-model="passForm.checkRemark"
              type="textarea"
              placeholder="请输入内容"
              :autosize="{ minRows: 6 }"
              size="mini"
            />
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isNopassshow = false">取 消</el-button>
        <el-button
          :loading="addLoading"
          :disabled="addLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="passSave"
          >提交</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import labelTree from "@/components/labelTree";
import { mapGetters } from "vuex";
import sideOrder from "@/components/sideOrder";
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
import LableShow from "@/components/lableShow";
export default {
  name: "",
  components: { labelTree, ElImageViewer, sideOrder,LableShow },
  computed: {
    ...mapGetters(["name"]),
  },
  data() {
    return {
      picList: [],
      logList: [],
      urlList: [],
      colorList: [],
      SemiSearch: {
        pageIndex: 1,
        pageSize: 100,
        likeWords: "",
        colorType: 0,
        colorState: -1,
      },
      isNopassshow: false,
      multipleSelection: [],
      isSemidialog: false,
      isAddMaterriel: false,
      currentItem: null,
      canDisablle: false,
      isShadeShow: false,
      marLoading: false,
      addLoading: false,
      isMarterdialog: false,
      showColor: false, // 选择物料
      orderNo: "", // 订单号
      loading: null,
      colorTypetList: [
        { colorTypeName: "普通", colorTypetNo: 1 },
        { colorTypeName: "专色", colorTypetNo: 2 },
      ],
      dataLoading: false, // 订单详情数据加载
      orderLoading: false, // 订单保存加载效果
      materForm: {
        colorSort: 1000,
        colorType: 1,
      },
      materFormRules: {
        colorName: [
          { required: true, message: "请输入颜色名称", trigger: "blur" },
        ],
        colorType: [
          { required: true, message: "请选择颜色类型", trigger: "blur" },
        ],
      },

      colorForm: {
        productCode: "", //订单产品代码
        colorList: [],
      },

      productFrom: {
        checkBillData: {},
        baseData: {},
        packageData: {},
        orderBaseData: {},
        orderTagDataList: [],
      },
      passFormrules: {
        checkRemark: [
          { required: true, message: "请输入原因", trigger: "change" },
        ],
      },
      addMaterrielLoading: false,
      isDisable: false, // 是否禁用输入框
      typeStatus: 0,
      passForm: {
        checkRemark: "",
      },
      rules: {},
    };
  },

  created() {
    this.getOrderDetail();
    // this.getLogs()
    // this.getTypeStatus()
    this.loading = this.$loading({
      lock: true,
      text: "数据加载中",
      spinner: "el-icon-loading",
      fullscreen: true,
      background: "rgba(0, 0, 0, 0.7)",
    });
  },
  deactivated() {
    // localStorage.removeItem('orderInit')
  },
  beforeDestroy() {
    // localStorage.removeItem('orderInit')
  },
  mounted() {
    // this.setSort()
    // this.calHeight()
  },
  methods: {
    // 表格最大高度
    calHeight() {
      this.$nextTick(() => {
        const rect = this.$refs.tableCon.getBoundingClientRect();
        this.tableHeight = rect.height;
      });
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

    //选择颜色
    handleSelectColor(){
      this.productFrom.printColorList.push({
        productCode:'',
        productTagCode:'',
        colorCode:'',
        colorReference:'',
        colorRemark:'',
        colorName:'',
        colorType:''
      })
    },

    changeExclusive() {
      this.openmater();
    },
    closePassDialog() {
      this.isNopassshow = false;
    },

    deleteRow(row, index) {
      this.productFrom.printColorList.splice(index, 1);
    },

    saveColorManuscript() {
      if(this.multipleSelection.length<1){
        this.$message.warning('请选择颜色')
        return
      }
      const array = JSON.parse(JSON.stringify(this.productFrom.printColorList));
      const arr = JSON.parse(JSON.stringify(this.multipleSelection));
      // arr.forEach(item => {
      //   item.applyGetQuantity = item.planUseQuantity
      //   item.getMaterialRemark = ''
      // })
      this.productFrom.printColorList = arr.reduce((result, item) => {
        console.log(item)
        const val = result.some(
          ({ colorCode }) => colorCode === item.colorCode
        );
        if (!val) {
          item.useType = 2; // 彩稿颜色
          result.push(item);
        }
        return result;
      }, array);
      this.closeSemiDialog();
    },
    closeSemiDialog() {
      this.isSemidialog = false;
    },

    // 规格列表
    openmater() {
      const parmas = this.SemiSearch;
      this.marLoading = true;
      this.$api.business
        .QueryPrintingColorDataList(parmas)
        .then((res) => {
          this.colorList = res;
          this.marLoading = false;
        })
        .catch(() => {
          this.marLoading = false;
        });
    },
    opanColor() {
      this.SemiSearch = {
        pageIndex: 1,
        pageSize: 100,
        likeWords: "",
        useType: 2,
        colorType: 0,
      };
      this.openmater();
    },

    // 新建颜色关闭
    closeDialog() {
      if (this.$refs.materForm) {
        this.$refs.materForm.resetFields();
      }
      this.materForm = this.$options.data().materForm;
      // this.isAddMaterriel = false
    },
    //
    addPackge() {
      this.isAddMaterriel = true;
    },

    // 继续新增
    reSaveMater() {
      const parmas = Object.assign(this.materForm, {});
      parmas.colorSort = Number(parmas.colorSort);
      this.$refs.materForm.validate((valid) => {
        if (valid) {
          this.addMaterrielLoading = true;
          this.$api.system
            .AddPrintingColor(parmas)
            .then(() => {
              this.addMaterrielLoading = false;
              this.materForm = {
                colorSort: 1000,
                colorType: "",
              };
              this.openmater();
              this.$message({
                message: "保存成功",
                type: "success",
              });
            })
            .catch(() => {
              this.addMaterrielLoading = false;
            });
        }
      });
    },
    // 保存
    saveMater() {
      const parmas = Object.assign(this.materForm, {});
      parmas.colorSort = Number(parmas.colorSort);
      this.$refs.materForm.validate((valid) => {
        if (valid) {
          this.addMaterrielLoading = true;
          this.$api.system
            .AddPrintingColor(parmas)
            .then(() => {
              this.isAddMaterriel = false;
              this.addMaterrielLoading = false;
              this.openmater();
              this.$message({
                message: "保存成功",
                type: "success",
              });
            })
            .catch(() => {
              this.addMaterrielLoading = false;
            });
        }
      });
    },

    openPass() {
      this.passForm.checkRemark = "";
    },
    // 审核通过
    passSH() {
      if (this.productFrom.printColorList.length < 1) {
        this.$message.warning("请选择颜色！");
        return;
      }
      // this.productFrom.printColorList.forEach((k)=>{
      //   if(!k.colorReference){
      //     this.$message.warning("请选择参考值");
      //     return
      //   }
      // })
      const { orderNo, agreementNo, productCode } = this.productFrom.orderBaseData

    const _coloList = []
      this.picList.forEach(e => {
        e.productTagCode = ''
      })

      this.productFrom.printColorList.forEach(e => {
        e.productCode = productCode
      })
      for (let index = 0; index < this.productFrom.printColorList.length; index++) {
        for (let index2 = 0; index2 < this.productFrom.orderTagDataList.length; index2++) {
          const a = this.productFrom.printColorList[index]
          const _d = JSON.parse(JSON.stringify(a))
          _d.productTagCode = this.productFrom.orderTagDataList[index2].productTagCode
          _coloList.push(_d)
        }
      }

      console.log(this.productFrom.orderTagDataList)
      this.productFrom.orderTagDataList.forEach((item) => {
        this.productFrom.printColorList.forEach((i) => {
          i.productCode = this.productFrom.orderBaseData.productCode
          this.colorForm.colorList.push({
            productTagCode: item.productTagCode, //产品标签代码
            colorCode: i.colorCode, //	颜色代码
            colorReference: i.colorReference, //颜色参考：1彩稿；2样表；3封样
            colorRemark: i.colorRemark, //颜色备注
          });
        });
      });

      const _data = {
        orderNo: this.productFrom.checkBillData.orderNo,
        checkBillID: this.productFrom.checkBillData.checkBillID,
        colorDraftNo: this.productFrom.checkBillData.colorDraftNo,
        checkResult: true,
        checkRemark: "",
        printColorList:_coloList
      };

      this.colorForm.productCode =
        this.productFrom.orderBaseData.productCode;

      // this.$api.business
      //   .SaveProductTagPrintColors(this.colorForm)
      //   .then(() => {});
      this.$api.business.ExcuteCheckColorDraft(_data).then((res) => {
        this.showAddDialog = false;
        this.$message({
          type: "success",
          message: "操作成功!",
        });
        this.getOrderDetail();
      });
    },
    // 撤审通过
    passCS() {
      this.productFrom.orderTagDataList.forEach((item) => {
        this.productFrom.printColorList.forEach((i) => {
          this.colorForm.colorList.push({
            productTagCode: item.productTagCode, //产品标签代码
            colorCode: i.colorCode, //	颜色代码
            colorReference: i.colorReference, //颜色参考：1彩稿；2样表；3封样
            colorRemark: i.colorRemark, //颜色备注
          });
        });
      });
      this.colorForm.productCode =
        this.productFrom.orderBaseData.productCode;

      this.$api.business
        .SaveProductTagPrintColors(this.colorForm)
        .then(() => {});
      const _data = {
        orderNo: this.productFrom.checkBillData.orderNo,
        checkBillID: this.productFrom.checkBillData.checkBillID,
        colorDraftNo: this.productFrom.checkBillData.colorDraftNo,
        checkResult: true,
        checkRemark: "",
      };
      this.$api.business.CheckCarefulCheckColorDraft(_data).then((res) => {
        this.showAddDialog = false;
        this.$message({
          type: "success",
          message: "操作成功!",
        });
        this.getOrderDetail();
      });
    },
    refush() {
      this.isNopassshow = true;
    },
    // 原因
    passSave() {
      if (this.productFrom.checkBillData.checkBillState === 0) {
        const _data = Object.assign(
          {
            orderNo: this.productFrom.checkBillData.orderNo,
            checkBillID: this.productFrom.checkBillData.checkBillID,
            colorDraftNo: this.productFrom.checkBillData.colorDraftNo,
            checkResult: false,
            printColorList:this.productFrom.printColorList
          },
          this.passForm,
          {}
        );
        this.$refs.passForm.validate((valid) => {
          if (valid) {
            this.$api.business.ExcuteCheckColorDraft(_data).then((res) => {
              this.showAddDialog = false;
              this.isNopassshow = false;
              this.$message({
                type: "success",
                message: "操作成功!",
              });
              this.getOrderDetail();
            });
          }
        });
      } else if (this.productFrom.checkBillData.checkBillState === 3) {
        const _data = Object.assign(
          {
            orderNo: this.productFrom.checkBillData.orderNo,
            checkBillID: this.productFrom.checkBillData.checkBillID,
            colorDraftNo: this.productFrom.checkBillData.colorDraftNo,
            checkResult: false,
          },
          this.passForm,
          {}
        );
        this.$refs.passForm.validate((valid) => {
          if (valid) {
            this.$api.business
              .CheckCarefulCheckColorDraft(_data)
              .then((res) => {
                this.showAddDialog = false;
                this.isNopassshow = false;
                this.$message({
                  type: "success",
                  message: "操作成功!",
                });
                this.getOrderDetail();
              });
          }
        });
      }
    },
    //
    addPackge() {
      this.isAddMaterriel = true;
    },
    // 预览彩稿
    previewColor(url) {
      this.isShadeShow = true;
      this.colorImagUrl = url;
    },
    onClose() {
      this.isShadeShow = false;
    },
    colosrSheBox() {
      this.isShadeShow = false;
    },
    // 获取订单详情
    getOrderDetail(id) {
      const _data = {
        checkBillID: this.$route.query.checkBillID,
      };
      this.$api.business.QueryColorDraftCheckBillDetail(_data).then((res) => {
        console.log(res);
        this.productFrom = res;
        this.picList = res.draftFileDataList;
        const ur = [];
        res.draftFileDataList.forEach((e) => {
          ur.push(e.draftFilePreviewUrl);
        });
        this.$nextTick(() => {
          this.urlList = ur;
        });
        this.loading.close();
      });

      //   const parmas = {
      //   saleOrderNo: this.$route.query.saleOrderNo
      // }
      // this.$api.business
      //   .GetSaleOrderDataByOrderNo(parmas)
      //   .then((res) => {
      //     this.productFrom = res
      //     this.loading.close()
      //   })
      //   .catch(() => {
      //     this.loading.close()
      //   })
    },
    // 控制标签内容层显示隐藏
    shrink(item) {
      this.$set(item, "isShow", !item.isShow);
    },
    // 初始化订单数据
    getInitOrder(oldOrderNo) {},
    // 返回
    Back() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang="scss" scoped>
</style>
<style lang="scss">
.el-loading-mask {
  top: 0;
}
</style>
